﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataAccess;

namespace QUANLYKHACHSAN_N4
{
    public partial class frmThemSuaDichVu : DevComponents.DotNetBar.Office2007Form
    {
        string mapt, map, madv, tendichvu = "";

        public frmThemSuaDichVu(string mapth, string maph, string madvu, string tdichvu, string sl)
        {
            InitializeComponent();
            mapt = mapth;
            map = maph;
            madv = madvu;
            cbDichVU.Text = tendichvu = tdichvu;
            txtSoLuong.Text = sl;
            btnOK.Text = "SỬA";
        }
        public frmThemSuaDichVu(string mapth, string maph)
        {
            InitializeComponent();
            mapt = mapth;
            map = maph;
            btnOK.Text = "THÊM";
        }

        private void frmThemSuaDichVu_Load(object sender, EventArgs e)
        {
            DuLieu.SetDataSource(cbDichVU, DichVu_Info.GetAll(), "tendichvu", "madichvu");
        }
        public bool acction=false;
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (tendichvu == "")//thuc hien them
            {
                if (DichVu_Info.AddChiTietPhieuThue(mapt, map, int.Parse(cbDichVU.SelectedValue.ToString()), int.Parse(txtSoLuong.Text)))
                {
                    acction = true;
                    this.Close();
                }
            }
            else
            {
                if (DichVu_Info.UpdateChiTietPhieuThue(mapt, map, int.Parse(madv), int.Parse(txtSoLuong.Text)))
                {
                    acction = true;
                    this.Close();
                }
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
